(function ($) {
    //预约挂号
    $.getMyorderUrl = {
        getpageUrl: function (urlName) {
            var yygh = {
                //取消预约
                cancelReservation: 'yygh/cancelReservation',
                //一级科室列表查询
                getDeptListTop: 'yygh/getDeptListTop',
                //二级科室列表查询
                getDeptListTwo: 'yygh/getDeptListTwo',
                //获取医生详情
                getDoctorDetail: 'yygh/getDoctorDetail',
                //医生列表查询
                getDoctorList: 'yygh/getDoctorList',
                //查询医院列表
                getHospitalList: 'yygh/getHospitalList',
                //获取就诊人信息
                getJzrInfo: 'yygh/getJzrInfo',
                //号源查询
                getNumSource: 'yygh/getNumSource',
                //号源查询(按专家)
                getNumSourceByYs: 'yygh/getNumSourceByYs',
                //预约单详情查询
                getOrderDetail: 'yygh/getOrderDetail',
                //预约单列表
                getOrderRecords: 'yygh/getOrderRecords',
                //号源预约
                submitOrderByUserInfo: 'yygh/submitOrderByUserInfo',
                //获取就诊信息
                getJzrInfo: "/yygh/getJzrInfo",
                
            };

            return "/api/ysd/" + yygh[urlName]
        }
    }

})(jQuery);



// function getCollectOerson(){
//     $.QuickRemote.AjaxJson({
//         funcName:"/api/ysd/hzcz/querySclb"
//         ,callback:function(result){     
//             if (result && result.length<1) {
//                 $("section").html("没有可预约的患者").css({"height" : "3rem","line-height" : "3rem",  "text-align" : "center"});
//             } else {
//                 initData();
//                 initView();
//             }
            
//         }
//     });
// }
function yyghSetControl() {
    /**选择就诊人*/
    $(".arrow-right,#jzr").on("click", function () {
        $.pageSwitch.goToUrl("signService", "collectResidents")
    });
    $(".qd-btn").on("click", function () {
        /**号源信息*/
        var hyInfo = StoreCache.getCache("YYGH_HYINFO");
        var hosInfo = StoreCache.getCache("YYGH_HOSINFO");
        var jzrInfo = $("#jzr").data("info");
        if(jzrInfo){
            var params = {};
            params["hosCode"] = hyInfo["hosCode"];
            params["depCode"] = hyInfo["depCode"];
            params["hosName"] = hosInfo ? hosInfo["hosName"] : hyInfo["hosName"];
            params["docCode"] = hyInfo["docCode"];
            params["doctName"] = hyInfo["docName"];
            // params["regType"] = hyInfo["regType"];
            params["numSourceCode"] = hyInfo["numSourceCode"];
            params["scheduleCode"] = hyInfo["numSourceCode"];
            params["payMode"] = "4";
            params["visitCost"] = hyInfo["visitCost"];
            params["payState"] = "2";
            params["password"] = "123456";

            params["patientCardType"] = "01";
            params["patientCardId"] = jzrInfo["sfzh"];

            params["patientPhone"] = jzrInfo["sj"];
            // params["patientName"] = jzrInfo["name"];
            params["userid"] = jzrInfo["xm"];
            params["patientGender"] = "1"; //jzrInfo["xb"];
            //  params["orderType"]="1";
            params["orderTime"] = hyInfo["scheduleDate"];
            params["timeRange"] = hyInfo["timeRange"];
            params["visitLevel"] = hyInfo["regType"];
            params["deptName"] = hyInfo["depName"];
            saveYyghInfo(params);
        }else{
            $.QuickAlert.alertFail({
                content : "请添加就诊人信息！"
            });
        }
    });


    function saveYyghInfo(params) {
        $.QuickRemote.AjaxJson({
            funcName: $.getMyorderUrl.getpageUrl("submitOrderByUserInfo")
            , callback: function (result) {

                $.QuickAlert.alertNormal("预约成功", {
                    callback: function () {
                        
                        $.pageSwitch.goToUrl("myOrder", "orderList")
                    }
                });
            }, params: params
        });

    }

    var info = StoreCache.getCache("ysdHzInfo");
    if (!StringUtils.isEmpty(info)) {
        var name = info["xm"];
        if (!StringUtils.isEmpty(name)) {
            $("#jzr").text(name);
        }
        $("#jzr").data("info", info);
    }
}
